<template>
	<view class="bg">
		<u-modal v-model="show" :content="content" :show-cancel-button='true' @confirm="define"></u-modal>
		<u-toast ref="uToast" />
		<u-form :model="tqxtFrom" ref="uForm" :rules="rules" label-width="160" :label-style="{
        fontSize: '24rpx',
        fontFamily: 'PingFang SC',
        fontWeight: '400',
        color: '#272B32',
      }">
			<view class="item">
				<u-form-item label="问题描述" label-position="top" :required="true" prop="wtms">
					<u-input v-model="tqxtFrom.wtms" type="textarea" />
				</u-form-item>
				<!-- <u-form-item label="上传附件" :required="true">
					<u-input disabled placeholder="请选取上传文件" type="file" />
					<u-upload ref="uUpload" :action="action" :auto-upload="false" width="100" height="50"
						:custom-btn="true">
						<view slot="addBtn" class="slot-btn">
							<image src="../../../../static/images/ZDXM/upload.png" mode="" />
						</view>
					</u-upload>
				</u-form-item>
				<view class="pre-box">
					<view class="pre-item" v-for="(item, index) in lists" :key="index">
						<image class="pre-item-image" :src="item.url" mode="aspectFill"></image>
					</view>
				</view> -->
			</view>
		</u-form>
		<view class="tqxt_buttons">
			<view>保存草稿</view>
			<view @click="Submit">提交</view>
		</view>
	</view>
</template>

<script>
	import {
		xmlcTqxt
	} from "@/request/zdxm.js"
	export default {
		data() {
			return {
				role: uni.getStorageSync('role'),
				show: false,
				content: '是否提交该问题描述',
				dataObj: {},
				tqxtFrom: {
					wtms: "",
				},
				rules: {
					wtms: [{
						required: true,
						message: '请输入问题描述内容',
						trigger: ['change', 'blur'],
					}],
				},
				action: "文件上传地址",
				lists: [],
			};
		},
		onLoad(option) {
			this.dataObj = JSON.parse(option.item)
		},
		onReady() {
			this.$refs.uForm.setRules(this.rules);
		},

		methods: {
			Submit() {
				this.$refs.uForm.validate(valid => {
					if (valid) {
						this.show = true
					} else {
						console.log('验证失败');
					}
				});
			},
			define() {
				this.dataObj.questionDescribe = this.tqxtFrom.wtms
				if (this.role === '2') {
					this.dataObj.projectStage = '2'
				}
				xmlcTqxt(
						this.dataObj
					)
					.then((res) => {
						if (res.data.code === 200) {
							this.$refs.uToast.show({
								title: res.data.message,
								type: "success",
								duration: 2000,
								callback() {
									uni.navigateBack({
									    delta: 1
									});
								}
							});
						}
					})
			}

		},
	};
</script>

<style lang="scss" scoped>
	.item {
		width: 710rpx;
		margin: 0 auto;
		margin-bottom: 30rpx;
		background: #ffffff;
		box-shadow: 0rpx 0rpx 24rpx 0rpx rgba(48, 116, 255, 0.1);
		border-radius: 8rpx;
		padding-left: 30rpx;
	}

	.tqxt_buttons {
		width: 100%;
		height: 98rpx;
		line-height: 98rpx;
		text-align: center;
		display: flex;
		flex-flow: row nowrap;
		justify-content: flex-start;
		align-content: center;
		position: fixed;
		bottom: 0;
		left: 0;

		view:nth-child(1) {
			flex: 1;
			background: #ffffff;
			border: 1rpx solid #e7e9f0;
			font-size: 36rpx;
			font-family: PingFang SC;
			font-weight: 500;
			color: #8e9cb3;
		}

		view:nth-child(2) {
			flex: 1;
			background: #3074ff;
			font-size: 36rpx;
			font-family: PingFang SC;
			font-weight: 500;
			color: #fefefe;
		}
	}

	.slot-btn {
		margin-right: 30rpx;
		display: flex;
		align-items: center;

		image {
			width: 40rpx;
			height: 40rpx;
		}
	}
</style>
